﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Creative85.Framework.Utilities
{
    public static class RandomUtility
    {
        private static Random random = new Random();

        public static readonly string Digit = "0123456789";
        public static readonly string Uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        public static readonly string Lowercase = "abcdefghijklmnopqrstuvwxyz";
        public static readonly string All = Digit + Uppercase + Lowercase;

        public static string GenerateRandomString(int length, char[] chars)
        {
            int charsLength = chars.Length;
            StringBuilder sb = new StringBuilder();
            for (int i = length - 1; i >= 0; i--)
            {
                sb.Append(chars[random.Next(0, charsLength)]);
            }
            return sb.ToString();
        }
        public static string GenerateRandomString(int length, string chars)
        {
            return GenerateRandomString(length, chars.ToCharArray());
        }
        public static string GenerateRandomString(int length)
        {
            return GenerateRandomString(length, All);
        }
    }
}
